﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using K9Nano.IM.Models;


namespace K9Nano.IM.Chat.ViewModels.ChatAppVMs
{
    public partial class ChatAppListVM : BasePagedListVM<ChatApp_View, ChatAppSearcher>
    {
        protected override List<GridAction> InitGridAction()
        {
            return new List<GridAction>
            {
                this.MakeStandardAction("ChatApp", GridActionStandardTypesEnum.Create, Localizer["Create"],"Chat", dialogWidth: 800),
                this.MakeStandardAction("ChatApp", GridActionStandardTypesEnum.Edit, Localizer["Edit"], "Chat", dialogWidth: 800),
                this.MakeStandardAction("ChatApp", GridActionStandardTypesEnum.Delete, Localizer["Delete"], "Chat", dialogWidth: 800),
                this.MakeStandardAction("ChatApp", GridActionStandardTypesEnum.Details, Localizer["Details"], "Chat", dialogWidth: 800),
                this.MakeStandardAction("ChatApp", GridActionStandardTypesEnum.BatchEdit, Localizer["BatchEdit"], "Chat", dialogWidth: 800),
                this.MakeStandardAction("ChatApp", GridActionStandardTypesEnum.BatchDelete, Localizer["BatchDelete"], "Chat", dialogWidth: 800),
                this.MakeStandardAction("ChatApp", GridActionStandardTypesEnum.Import, Localizer["Import"], "Chat", dialogWidth: 800),
                this.MakeStandardAction("ChatApp", GridActionStandardTypesEnum.ExportExcel, Localizer["Export"], "Chat"),
            };
        }


        protected override IEnumerable<IGridColumn<ChatApp_View>> InitGridHeader()
        {
            return new List<GridColumn<ChatApp_View>>{
                this.MakeGridHeader(x => x.Name),
                this.MakeGridHeader(x => x.Secret),
                this.MakeGridHeader(x => x.CustomerInfoCallback),
                this.MakeGridHeader(x => x.CustomerOrderCallback),
                this.MakeGridHeaderAction(width: 200)
            };
        }

        public override IOrderedQueryable<ChatApp_View> GetSearchQuery()
        {
            var query = DC.Set<ChatApp>()
                .Select(x => new ChatApp_View
                {
				    ID = x.ID,
                    Name = x.Name,
                    Secret = x.Secret,
                    CustomerInfoCallback = x.CustomerInfoCallback,
                    CustomerOrderCallback = x.CustomerOrderCallback,
                })
                .OrderBy(x => x.ID);
            return query;
        }

    }

    public class ChatApp_View : ChatApp{

    }
}
